{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号： \n",
    "+ 姓名  张凡\n",
    "+ 学号  0165194"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "家庭1：\n",
      "是贫困户\n",
      "义务教育需要扶持\n",
      "住房需要扶持\n",
      "饮水需要扶持\n",
      "\n",
      "家庭2：\n",
      "不是贫困户\n",
      "\n",
      "家庭3：\n",
      "不是贫困户\n"
     ]
    }
   ],
   "source": [
    "class pinkunhu():\n",
    "    def _init_(self,x1,x2,x3,x4):\n",
    "        self.youbaozhang=x1\n",
    "        self.kezhufang=x2\n",
    "        self.keyinshui=x3\n",
    "        self.youdanbai=x4\n",
    "        \n",
    "    def jiaoyu(self,xuefei):\n",
    "        if xuefei>=500:\n",
    "            self.youbaozhang=True\n",
    "        else:\n",
    "            self.youbaozhang=False\n",
    "            \n",
    "    def zhufang(self,nianshu):\n",
    "        if nianshu>=50:\n",
    "            self.kezhufang=False\n",
    "        else:\n",
    "            self.kezhufang=True\n",
    "            \n",
    "    def yinshui(self,zazhi):\n",
    "        if zazhi>3:\n",
    "            self.keyinshui=False\n",
    "        else:\n",
    "            self.keyinshui=True\n",
    "            \n",
    "    def shiwu(self,zhonglei):\n",
    "        if zhonglei>=2:\n",
    "            self.youdanbai=True\n",
    "        else :\n",
    "            self.youdanbai=False\n",
    "            \n",
    "def panding(self):\n",
    "    count=0\n",
    "    if self.youbaozhang==False:\n",
    "        count+=1\n",
    "    if self.kezhufang==False:\n",
    "        count+=1\n",
    "    if self.keyinshui==False:\n",
    "        count+=1\n",
    "    if self.youdanbai==False:\n",
    "        count+=1\n",
    "    if count>2:\n",
    "        print('是贫困户')\n",
    "        if self.youbaozhang==False:\n",
    "            print('义务教育需要扶持')\n",
    "        if self.kezhufang==False:\n",
    "            print('住房需要扶持')\n",
    "        if self.keyinshui==False:\n",
    "            print('饮水需要扶持')\n",
    "        if self.youdanbai==False:\n",
    "            print('肉蛋奶豆需要扶持')\n",
    "       \n",
    "    else:\n",
    "        print('不是贫困户')\n",
    "    \n",
    "    \n",
    "            \n",
    "jiating1=pinkunhu()\n",
    "jiating2=pinkunhu()\n",
    "jiating3=pinkunhu()\n",
    "\n",
    "##jiating1\n",
    "jiating1.jiaoyu(xuefei=300)\n",
    "jiating1.zhufang(nianshu=70)\n",
    "jiating1.yinshui(zazhi=5)\n",
    "jiating1.shiwu(zhonglei=4)\n",
    "print('\\n家庭1：')\n",
    "panding(jiating1)\n",
    "\n",
    "\n",
    "##jiating\n",
    "jiating2.jiaoyu(xuefei=700)\n",
    "jiating2.zhufang(nianshu=70)\n",
    "jiating2.yinshui(zazhi=2)\n",
    "jiating2.shiwu(zhonglei=2)\n",
    "print('\\n家庭2：')\n",
    "panding(jiating2)\n",
    "\n",
    "##jiating3\n",
    "jiating3.jiaoyu(xuefei=500)\n",
    "jiating3.zhufang(nianshu=40)\n",
    "jiating3.yinshui(zazhi=5)\n",
    "jiating3.shiwu(zhonglei=1)\n",
    "print('\\n家庭3：')\n",
    "panding(jiating3)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "小红BIM可能偏大\n",
      "小绿体重正常\n",
      "小蓝BIM可能偏大\n"
     ]
    }
   ],
   "source": [
    "class Student(object):\n",
    "    \n",
    "    def __init__(self, name, score ,hours):\n",
    "        self.name = name\n",
    "        self.score = score\n",
    "        self.hours = hours\n",
    "        \n",
    "    def get_grade(self,c1,c2):\n",
    "        \n",
    "        if self.score > c1 & self.hours<c2 :\n",
    "            print('%sBIM可能偏大'%self.name)\n",
    "            \n",
    "        else:\n",
    "            print('%s体重正常'%self.name)\n",
    "    \n",
    "person1=Student('小红',95,6)\n",
    "person2=Student('小绿',75,8)\n",
    "person3=Student('小蓝',93,4)\n",
    "\n",
    "person1.get_grade(90,6)\n",
    "person2.get_grade(90,6)\n",
    "person3.get_grade(90,6)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "小红BIM可能偏大\n",
      "小绿体重正常\n",
      "小蓝趋向正常\n"
     ]
    }
   ],
   "source": [
    "class run_club(Student):\n",
    "    \n",
    "    def __init__(self, name, score ,hours,run):\n",
    "        super().__init__(name, score ,hours)\n",
    "        self.run=run\n",
    "    def get_grade(self,c1,c2):\n",
    "        \n",
    "        if self.score > c1 & self.hours<c2 :\n",
    "            if self.run>30:\n",
    "                print('%s趋向正常'%self.name)\n",
    "            else:\n",
    "                print('%sBIM可能偏大'%self.name)\n",
    "            \n",
    "        else:\n",
    "            print('%s体重正常'%self.name)\n",
    "            \n",
    "person1=run_club('小红',95,6,20)\n",
    "person2=run_club('小绿',75,8,29)\n",
    "person3=run_club('小蓝',93,4,50)\n",
    "\n",
    "person1.get_grade(90,6)\n",
    "    \n",
    "person2.get_grade(90,6)\n",
    "\n",
    "person3.get_grade(90,6)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
